package tfsIssueTracker;

import jetbrains.buildServer.vcs.VcsException;
import org.apache.commons.httpclient.Credentials;
import org.apache.commons.httpclient.UsernamePasswordCredentials;

import java.io.File;

/**
 * Created by IntelliJ IDEA.
 * User: Simone
 * Date: 28-nov-2010
 * Time: 21.13.10
 * To change this template use File | Settings | File Templates.
 */
public class Settings {
    private String password;
    private String username;
    private String host;
    private File wrapper;

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getUsername() {
        return username;
    }

    public void setHost(String host) {
        this.host = host;
    }

    public String getHost() {
        return host;
    }

    public void setWrapper(File wrapper) {
        this.wrapper = wrapper;
    }

    public File getWrapper() {
        return wrapper;
    }

    public static Settings create(String host, Credentials credentials, TfsExeWrapper wrapper) throws VcsException {
        Settings mySettings = new Settings();

        mySettings.setWrapper(wrapper.getExeFile());
        mySettings.setHost(host);

        if(credentials != null) {
            UsernamePasswordCredentials localCredentials = (UsernamePasswordCredentials)credentials;
            mySettings.setPassword(localCredentials.getPassword());
            mySettings.setUsername(localCredentials.getUserName());
        }

        return mySettings;
    }
}
